// 多态
package main

import "fmt"

type notifier interface {
    notify()
}

type user struct {
    name string
    email string
}

func (u *user) notify() {
    fmt.Printf("Sending user email to %s<%s>\n", u.name, u.email)
}

type admin struct {
    name string
    email string
}

func (a *admin) notify() {
    fmt.Printf("Sending admin email to %s<%s>\n", a.name, a.email)
}

type foo struct {
    name string
    email string
}

func (f foo) notify() {
    fmt.Printf("[value] Sending foo email to %s<%s>\n", f.name, f.email)
}

func sendNotification(n notifier) {
    n.notify()
}

func main() {
    bill := user {"Bill", "bill@email.com"}
    sendNotification(&bill)

    lisa := admin {"Lisa", "lisa@email.com"}
    sendNotification(&lisa)

    jack := foo {"Jack", "jack@email.com"}
    sendNotification(jack) // use value
}
